package org.dftproject.genesis.ui.actions;

import org.dftproject.genesis.ui.Activator;
import org.dftproject.genesis.ui.pages.PageManager;
import org.dftproject.genesis.ui.pages.home.HomePage;
import org.dftproject.genesis.ui.pages.home.HomePageInput;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;

public class HomeAction extends Action {
	
	public static final String ID = HomeAction.class.getName();
	
	private final IWorkbenchWindow window;
	
	public HomeAction(IWorkbenchWindow window, String label) {
		this.window = window;
		setText(label);
		setId(ID);
		setActionDefinitionId(ID);
		setImageDescriptor(Activator.getImageDescriptor("/icons/house.png"));
	}
	
	@Override
	public void run() {
		if (window != null) {	
			IWorkbenchPage workbenchPage = window.getActivePage();
			PageManager.getDefault().openPage(workbenchPage, new HomePageInput(), HomePage.ID, true, false);
		}
	}
}
